class HttpException extends Error {
  constructor({msg = '服务器异常', errno = 10000, code = 500}) {
    super();
    this.errno = errno; // 服务器自定义错误状态码
    this.code = code; // http状态码
    this.msg = msg; // 自定义信息
  }
}

class Success extends HttpException {
  constructor({data, msg, code}) {
    super({
      msg: msg || 'no problem',
      errno: 0,
      code: code || 200
    });
    this.data = data;
  }
}

class Fail extends HttpException {
  constructor({msg, errno, code}) {
    super({
      msg: msg || 'something wrong u made',
      errno,
      code: code || 400
    });
  }
}

// 用于请求参数校验时
class ParameterException extends HttpException {
  constructor({msg}) {
    super({
      msg: msg || '参数错误',
      errno: 100000, // emmm lin-validator设计失误 So这里不能改变
      code: 400
    });
  }
}

module.exports = {
  HttpException
  , Success
  , Fail
  , ParameterException
};
